// This is a basic Flutter widget test for the Shake Detection Demo app.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';

void main() {
  testWidgets('Shake Detection Demo app smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(const MyApp());

    // Verify that the app title is correct.
    expect(find.text('Shake Detection Demo'), findsOneWidget);
    
    // Verify that the initial shake info is displayed.
    expect(find.text('No shake detected yet'), findsOneWidget);
    
    // Verify that the settings section is present.
    expect(find.text('Settings:'), findsOneWidget);
    expect(find.text('Sensitivity'), findsOneWidget);
    expect(find.text('Use Noise Filter'), findsOneWidget);
    expect(find.text('Minimum Shake Count'), findsOneWidget);
    
    // Verify that the Apply Settings button is present.
    expect(find.text('Apply Settings'), findsOneWidget);
    
    // Verify that the instruction text is present.
    expect(find.text('Shake your device to test!'), findsOneWidget);
    
    // Test tapping the Apply Settings button.
    await tester.tap(find.text('Apply Settings'));
    await tester.pump();
    
    // The app should still be functional after applying settings.
    expect(find.text('Shake Detection Demo'), findsOneWidget);
  });
  
  testWidgets('Settings interaction test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(const MyApp());
    
    // Find and interact with the noise filter switch.
    final switchFinder = find.byType(Switch);
    expect(switchFinder, findsOneWidget);
    
    // Tap the switch to toggle noise filter.
    await tester.tap(switchFinder);
    await tester.pump();
    
    // The app should still be functional.
    expect(find.text('Shake Detection Demo'), findsOneWidget);
  });
}
